package com.yunxi.service.localService.impl.sat;

import com.github.pagehelper.PageInfo;
import com.yunxi.core.page.PageHelperPlus;
import com.yunxi.core.service.ServiceImplPlus;
import com.yunxi.dao.sat.SatCustomerFollowMapper;
import com.yunxi.model.sat.SatCustomerFollow;
import com.yunxi.sat.pojo.*;
import com.yunxi.service.localService.sat.SatCustomerFollowService;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 客户跟进记录表 服务实现类
 * </p>
 *
 * @author caoYong
 * @since 2019-07-11
 */
@Service
public class SatCustomerFollowServiceImpl extends ServiceImplPlus<SatCustomerFollowMapper, SatCustomerFollow> implements SatCustomerFollowService {

    /**
     * 根据客户编号,领取人查询最新一条线索
     * @param satCustomerFollow
     * @return
     */
    @Override
    public SatCustomerClueVO getCustomerClueInfo(SatCustomerFollow satCustomerFollow) {
        return baseMapper.getCustomerClueInfo(satCustomerFollow);
    }

    /**
     * 更新客户级别
     * @param satCustomerFollowVO
     * @throws Exception
     */
    @Override
    public void updateCustomerLevel(SatCustomerFollowVO satCustomerFollowVO) throws Exception {
        baseMapper.updateCustomerLevel(satCustomerFollowVO);
    }

    @Override
    public String getCustomerLevelByNo(SatCustomerFollowVO satCustomerFollowVO) throws Exception {
        return baseMapper.getCustomerLevelByNo(satCustomerFollowVO);
    }

    /**
     * 待跟进客户
     * @param satCustomerFollowVO
     * @return
     * @throws Exception
     */
    @Override
    public List<SatCustomerFollowVO> waitFollow(SatCustomerFollowVO satCustomerFollowVO) throws Exception {
        return baseMapper.waitFollow(satCustomerFollowVO);
    }

    @Override
    public PageInfo<SatCustomerFollowVO> waitFollowForPage(SatCustomerFollowVO satCustomerFollowVO, Integer pageNum, Integer pageSize) throws Exception {
        PageHelperPlus.startPage(pageNum,pageSize);
        List<SatCustomerFollowVO> list = baseMapper.waitFollow(satCustomerFollowVO);
        PageInfo<SatCustomerFollowVO> pageInfo = new PageInfo<SatCustomerFollowVO>(list);
        return pageInfo;
    }

    /**
     * 逾期跟进客户
     * @param satCustomerFollowVO
     * @return
     * @throws Exception
     */
    @Override
    public List<SatCustomerFollowVO> lateFollow(SatCustomerFollowVO satCustomerFollowVO) throws Exception {
        return baseMapper.lateFollow(satCustomerFollowVO);
    }

    @Override
    public PageInfo<SatCustomerFollowVO> lateFollowForPage(SatCustomerFollowVO satCustomerFollowVO, Integer pageNum, Integer pageSize) throws Exception {
        PageHelperPlus.startPage(pageNum,pageSize);
        List<SatCustomerFollowVO> list = baseMapper.lateFollow(satCustomerFollowVO);
        PageInfo<SatCustomerFollowVO> pageInfo = new PageInfo<SatCustomerFollowVO>(list);
        return pageInfo;
    }

    /**
     * 老客户跟进
     * @param satCustomerFollowVO
     * @return
     * @throws Exception
     */
    @Override
    public List<SatCustomerFollowVO> goodCustomerFollow(SatCustomerFollowVO satCustomerFollowVO) throws Exception {
        return baseMapper.goodCustomerFollow(satCustomerFollowVO);
    }

    @Override
    public PageInfo<SatCustomerFollowVO> goodCustomerFollowForPage(SatCustomerFollowVO satCustomerFollowVO, Integer pageNum, Integer pageSize) throws Exception {
        PageHelperPlus.startPage(pageNum,pageSize);
        List<SatCustomerFollowVO> list = baseMapper.goodCustomerFollow(satCustomerFollowVO);
        PageInfo<SatCustomerFollowVO> pageInfo = new PageInfo<SatCustomerFollowVO>(list);
        return pageInfo;
    }

    /**
     * 今日跟进提醒报表
     * @param followRemindVO
     * @return
     * @throws Exception
     */
    @Override
    public FollowRemindVO followRemind(FollowRemindVO followRemindVO) throws Exception {
        return baseMapper.followRemind(followRemindVO);
    }

    @Override
    public FollowRemindVO manageFollowRemind(FollowRemindVO followRemindVO) throws Exception {
        return baseMapper.manageFollowRemind(followRemindVO);
    }

    @Override
    public List<SatCustomerFollowVO> getFollowsByNo(SatCustomerFollowVO satCustomerFollowVO)throws Exception{
        return baseMapper.getFollowsByNo(satCustomerFollowVO);
    }

    /**
     * 根据字典key查询中文
     * @param parentKey
     * @return
     */
    @Override
    public String queryDictCn(String parentKey, String key) {
        SatCustomerFollowDictVO satCustomerFollowDictVO = new SatCustomerFollowDictVO();
        satCustomerFollowDictVO.setParentKey(parentKey);
        satCustomerFollowDictVO.setKey(key);
        return baseMapper.queryDictCn(satCustomerFollowDictVO);
    }

    /**
     * 查询每日待跟进数量
     * @param satCustomerFollowCountVO
     * @return
     * @throws Exception
     */
    @Override
    public List<SatCustomerFollowCountVO> getWaitFollowCount(SatCustomerFollowCountVO satCustomerFollowCountVO) throws Exception {
        return baseMapper.getWaitFollowCount(satCustomerFollowCountVO);
    }
}
